<template>
  <div class="app-container">
    {{$t('setting.Flash_screen_setting')}}
    <div class="content">
      <img :src="imgPic" style="width:300px;height:400px;display:block;border:1px solid #ccc" alt="">
        <el-upload
          action=""
          class="upload-demo"
          :http-request="fileUploads"
          :limit="1"
          list-type="picture">
        <el-button size="small" type="primary" style="margin-top:30px"> {{$t('common.Click_to_upload')}}</el-button>
        <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div> -->
      </el-upload>
    </div>
   </div>
</template>

<script>
import { getSystemParamter , updateSystemParamter, fileUpload } from '@/api/system'
export default {
  name: 'setting_page',
  data(){
    return{
      fileList: [],
      currentIndex: 0,
      currentId: '',
      file: [],
      imgPic: ''
    }
  },
  methods:{
    // 获取列表
    async getList(){
      const { data } = await getSystemParamter({
        key:'SYS00013',
      })
      this.imgPic = data.systemValue
    },
    // 上传列表
    async postList(file){
      console.log(file);
      const { data } = await updateSystemParamter({
        key:"SYS00013",
        value:file,
      })
      this.getList()
    },
    //上传图片
    async fileUploads({file}) {
      try{
        const fd = new FormData()
        fd.append('file', file)
        fd.append('fileName', 'indexPic')
        const res = await fileUpload(fd)
        this.postList(res.data)
      }catch(error) {

      }
    },
  },
  created(){
    this.getList()
  }
}
</script>

<style>
.content{
  margin-top:30px;
  margin-left:12px;
  width: 500px;
}
</style>
